package cn.iocoder.yudao.module.reading.controller.app.audio.vo;

import cn.iocoder.yudao.module.reading.framework.vo.BaseUrlConvertVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 音频资源 Response VO
 *
 * @author 芋道源码
 */
@Schema(description = "用户 APP - 音频资源 Response VO")
@Data
@EqualsAndHashCode(callSuper = false)
public class AudioResourceRespVO extends BaseUrlConvertVO {

    @Schema(description = "音频资源ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long id;

    @Schema(description = "音频标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "The Magic Key")
    private String title;

    @Schema(description = "音频文件URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://example.com/audio1.mp3")
    private String audioUrl;

    @Schema(description = "封面图片URL", example = "https://example.com/cover1.jpg")
    private String cover;

    @Schema(description = "音频时长（秒）", requiredMode = Schema.RequiredMode.REQUIRED, example = "180")
    private Integer duration;

    @Schema(description = "音频分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "english")
    private String category;

    @Schema(description = "语言类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "en")
    private String language;

    @Schema(description = "音频副标题/描述", example = "Oxford Reading Tree Level 1")
    private String subtitle;

    @Schema(description = "音频时长（格式化字符串）", example = "03:00")
    private String durationText;

    @Schema(description = "关联绘本ID", example = "10")
    private Long bookId;

    @Schema(description = "关联绘本集ID", example = "5")
    private Long bookSetId;

    @Schema(description = "排序权重", example = "100")
    private Integer sortOrder;

    @Schema(description = "是否启用", example = "true")
    private Boolean enabled;

    @Schema(description = "播放次数", example = "5")
    private Integer playCount;

    @Schema(description = "点赞数", example = "10")
    private Integer likeCount;

    @Schema(description = "是否已点赞", example = "false")
    private Boolean isLiked;

    @Schema(description = "是否已收藏", example = "true")
    private Boolean isFavorited;

    @Schema(description = "播放状态")
    private PlayStatusVO playStatus;

    @Schema(description = "播放状态")
    @Data
    public static class PlayStatusVO {
        @Schema(description = "播放进度（秒）", example = "60")
        private Integer playProgress;

        @Schema(description = "是否播放完成", example = "false")
        private Boolean isCompleted;

        @Schema(description = "播放次数", example = "3")
        private Integer playCount;

        @Schema(description = "最后播放时间", example = "2024-01-06T10:30:00")
        private String lastPlayAt;
    }

    /**
     * 转换URL字段
     * 将相对路径转换为完整URL
     */
    @Override
    public void convertUrls() {
        this.audioUrl = convertUrl(this.audioUrl);
        this.cover = convertUrl(this.cover);
    }
}
